feat: add default app and manifest watch config#89
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #89 +/- ##
=======================================
Coverage 94.68% 94.68%
=======================================
Files 11 11
Lines 207 207
=======================================
Hits 196 196
Misses 11 11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
WilliamBergamin
left a comment
There was a problem hiding this comment.
Tested this out locally 🚀 The experience is much better then I expected 🌟
My only concern before merging this is that the CLI seems to be using a keyboard interrupt to stop the process and this is leading to a traceback being printed 🤔 I don't think this traceback should be printed when the CLI does its "refresh"
INFO:slack_bolt.App:Starting to receive messages from a new connection (session id: c946512435)
App change detected: ~/bolt-python-search-template/listeners/functions/search.py, restarting server...
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "~/bolt-python-search-template/.venv/lib/python3.13/site-packages/slack_cli_hooks/hooks/start.py", line 44, in <module>
start(os.getcwd())
~~~~~^^^^^^^^^^^^^
File "~/bolt-python-search-template/.venv/lib/python3.13/site-packages/slack_cli_hooks/hooks/start.py", line 37, in start
runpy.run_path(entrypoint_path, run_name="__main__")
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen runpy>", line 287, in run_path
File "<frozen runpy>", line 98, in _run_module_code
File "<frozen runpy>", line 88, in _run_code
File "~/bolt-python-search-template/app.py", line 19, in <module>
SocketModeHandler(app, os.environ.get("SLACK_APP_TOKEN")).start()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "~/bolt-python-search-template/.venv/lib/python3.13/site-packages/slack_bolt/adapter/socket_mode/base_handler.py", line 58, in start
Event().wait()
~~~~~~~~~~~~^^
File "/Users/wbergamin/.pyenv/versions/3.13.1/lib/python3.13/threading.py", line 659, in wait
signaled = self._cond.wait(timeout)
File "/Users/wbergamin/.pyenv/versions/3.13.1/lib/python3.13/threading.py", line 359, in wait
waiter.acquire()
~~~~~~~~~~~~~~^^
KeyboardInterruptNot sure if this is something we could handle on the CLI side 🤔 from my quick search it seems like sending a syscall.SIGTERM to the python process might prevent this tracback log from showing up
|
@WilliamBergamin Thanks a ton for taking this for a spin! 🚲 ✨ IIRC Windows doesn't support the same
🔗 https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/signal?view=msvc-170 I agree we might find improvements to these outputs - perhaps clearing the screen between restarts is useful - but for now this output might be alright toward iterations in app development? |
mwbrooks
left a comment
There was a problem hiding this comment.
✅ This works so well, I can't wait for it to land in the CLI's next release 😄
🧪 Local testing works well! 👾
💭 @WilliamBergamin raises a good point. I've noticed the same error output when we CTRL+C the slack run process. The error output isn't the most pleasant experience and it's good to know that we can solve it by using the syscall.SIGTERM on Unix/macOS.
My suggestion is that we can merge this PR and follow-up with a CLI improvement that uses syscall.SIGTERM on a Unix/macOS and falls back on KeyboardInterrupt for Windows and other platforms. Since the experience already exists on CTRL+C.
| "watch": { | ||
| "app": { | ||
| "filter-regex": "\\.py$", | ||
| "paths": ["."], | ||
| }, | ||
| "manifest": { | ||
| "paths": ["manifest.json"], | ||
| }, | ||
| }, |
There was a problem hiding this comment.
praise: So much simpler than the @slack/cli-hooks PR! 😆
|
@mwbrooks Thanks for suggesting a path forward in these changes. I agree that we can add sophistication to this experience as more feedback is shared. @WilliamBergamin @mwbrooks Both of y'all's testing goes so far! Let's merge this now for a soon release 🚢 💨 |
Summary
This PR adds a default
appandmanifestoption to file watching for server restarts and app reinstalls.Following: slackapi/slack-cli#310
Testing
Build these changes with the CLI changes noted above. Then reinstall and reload an app:
Special notes
CLI version >=3.12.0 is required for these changes to be used in development, but these will be released in order or together if all goes well in review 👾
Requirements
./scripts/install_and_run_tests.shafter making the changes.